<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>symbol</title>
</head>
<body>
<script>
Function.prototype.call = function (context, ...args) {
	context = context || window;
	console.log(this);//this 指向要执行的函数
	const fnSymbol = Symbol('fn');
	context[fnSymbol] = this;
	context[fnSymbol](...args);
	delete context[fnSymbol];
}
function foo2(x, y) {
	console.log(this.a);
	console.log(x, y);
}
var obj2 = {
	a: 2
};
foo2.call(obj2, 22, 33);//2
</script>
<script>
Function.prototype.apply = function(context, args) {
	context = context || window;
	console.log(this);//this 指向要执行的函数
	const fnSymbol = Symbol('fn');
	context[fnSymbol] = this;
	context[fnSymbol](...args);
	delete context[fnSymbol];
}
foo2.apply(obj2, [22, 33]);//2
</script>
<script type="text/javascript">
Function.prototype.bind = function(context, args) {
	context = context || window;
	const fnSymbol = Symbol('fn');
	context[fnSymbol] = this;
	return function (..._args) {
		args = args.concat(_args);
		context[fnSymbol](...args);
		delete context[fnSymbol];
	};
}
const foo3 = foo2.bind(obj2, [22, 33]);
console.log(foo3);
foo3(44, 55);
</script>
</body>
</html>